import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

import { BaseService } from '../base.service';
import { CardInfo } from '../card-info/card-info.service';

export interface CardRegex {
  id?: number;
  regexexpression: string;
}

@Injectable({
  providedIn: 'root'
})
export class CardRegexService extends BaseService<CardRegex> {
  constructor() {
    super();
    this.apiPrefix = 'cardregex';
  }

  public ValidateCardRegex(pattern: string, content: string): Observable<CardInfo[]> {
    return this.http.post<CardInfo[]>(`/${this.apiPrefix}/ValidateRegex`, { pattern: pattern, content: content }, { needSuccessInfo: false, showLoading: true });
  }
}
